home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #9 / Amiga Plus CD - 2004 - No. 09.iso / amigaplus / tools / amigaos4_only / fracblank / source / fracgui.c < prev    next >
Text File  |  2004-08-03  |  21KB  |  792 lines

  1. /*
  2. **  FracBlank - AmigaDOS 2.04 commodities utility screenblanker
  3. **
  4. **  Copyright © 1991-1995 by Olaf `Olsen' Barthel
  5. **    All Rights Reserved
  6. **
  7. **  Cosmic flame fractal code derived from xlock source code
  8. **
  9. **  Copyright © 1988-1991 by Patrick J. Naughton.
  10. */
  11.  
  12. /* EditRoutine():
  13.  *
  14.  *  A special string gadget editing routine for key
  15.  *  combination input.
  16.  */
  17.  
  18. ULONG EditRoutine(struct Hook *Hook, struct SGWork *Work, ULONG *Msg) {
  19.  
  20.   struct InputEvent Event;
  21.  
  22.   ULONG  Qualifier;
  23.   UWORD  Code;
  24.   UBYTE  Key[10];
  25.   WORD   KeyLen;
  26.   STRPTR KeyName;
  27.  
  28.   // If the gadget just got activated or the caps lock key
  29.   // is active, don't change anything
  30.  
  31.   if (*Msg == SGH_CLICK || (*Msg == SGH_KEY && (Work->IEvent->ie_Qualifier & IEQUALIFIER_CAPSLOCK))) return(TRUE);
  32.   else {
  33.     // Complain if this is not what we expect to be fun
  34.     if(*Msg != SGH_KEY) return(FALSE);
  35.   }
  36.  
  37.   // Ditch the qualifier keys
  38.  
  39.   if (Work->IEvent->ie_Code >= 96 && Work->IEvent->ie_Code <= 103) {
  40.     Work->Actions &= ~(SGA_USE | SGA_BEEP);
  41.     return(TRUE);
  42.   }
  43.  
  44.   // Strip all the qualifiers we don't want
  45.  
  46.   Qualifier = Work->IEvent->ie_Qualifier & ~(IEQUALIFIER_REPEAT | IEQUALIFIER_INTERRUPT | IEQUALIFIER_MULTIBROADCAST | IEQUALIFIER_RELATIVEMOUSE);
  47.  
  48.   // Check for raw keys
  49.  
  50.   switch(Work->IEvent->ie_Code) {
  51.     case RAWKEY_CURSOR_UP:
  52.     case RAWKEY_CURSOR_DOWN:
  53.     case RAWKEY_CURSOR_RIGHT:
  54.     case RAWKEY_CURSOR_LEFT:
  55.       // A cursor key was pressed, check if there
  56.       // is probably some special feature involved
  57.       if (!(Qualifier & ~(IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))) return(TRUE);
  58.       // FALLS THROUGH TO:
  59.     case RAWKEY_F1:
  60.     case RAWKEY_F2:
  61.     case RAWKEY_F3:
  62.     case RAWKEY_F4:
  63.     case RAWKEY_F5:
  64.     case RAWKEY_F6:
  65.     case RAWKEY_F7:
  66.     case RAWKEY_F8:
  67.     case RAWKEY_F9:
  68.     case RAWKEY_F10:
  69.     case RAWKEY_HELP:
  70.       // Ok, so this is a raw key event
  71.       Code = Work->IEvent->ie_Code;
  72.       KeyLen = 0;
  73.       break;
  74.     default:
  75.       // Make a copy of the inputevent and
  76.       // clear the qualifier bits
  77.       IExec->CopyMem(Work->IEvent,&Event,sizeof(struct InputEvent));
  78.       Event.ie_Qualifier = NULL;
  79.       Code = 0;
  80.       // Translate the event
  81.       if ((KeyLen = IKeymap->MapRawKey(&Event,Key,10,NULL)) < 0) KeyLen = 10;
  82.       break;
  83.   }
  84.  
  85.   // Is the user holding down a single Amiga key?
  86.  
  87.   if (KeyLen && (Qualifier & IEQUALIFIER_RCOMMAND) && !(Qualifier & ~IEQUALIFIER_RCOMMAND)) {
  88.     UBYTE Char = IUtility->ToUpper(Key[0]);
  89.     // Undo and clear are supported
  90.     if (Char == 'Q' || Char == 'X') return(TRUE);
  91.   }
  92.  
  93.   // Can we safely continue?
  94.  
  95.   if ((!Code && !KeyLen) || KeyLen > 1 || (!Code && KeyLen && !Key[0])) {
  96.     Work->Actions = (Work->Actions & ~SGA_USE) | SGA_BEEP;
  97.     return(TRUE);
  98.   }
  99.  
  100.   // Take care of special characters
  101.  
  102.   if (KeyLen) {
  103.     static struct {
  104.       UBYTE  Code;
  105.       STRPTR Name;
  106.     } KeyTable[] = {
  107.       '\r',  "Return",
  108.       '\b',  "Backspace",
  109.       '\033',"Escape",
  110.       ' ',   "Spacebar",
  111.       ',',   "Comma",
  112.       '\177',"Delete",
  113.       '\t',  "Tab",
  114.       0
  115.     };
  116.     BOOL GotIt = FALSE;
  117.     WORD i;
  118.     // Carriage return was pressed
  119.     if (Key[0] == '\r') {
  120.       // This probably ends input
  121.       if (!Qualifier) {
  122.         Work->Actions  = (Work->Actions & ~SGA_BEEP) | SGA_USE | SGA_END;
  123.         return(TRUE);
  124.       }
  125.       else {
  126.         // Is this the enter key?
  127.         if (Qualifier & IEQUALIFIER_NUMERICPAD) {
  128.           KeyName = "Enter";
  129.           Qualifier &= ~IEQUALIFIER_NUMERICPAD;
  130.           GotIt = TRUE;
  131.         }
  132.       }
  133.     }
  134.     // If this is just the tab key, pass it through cleanly
  135.     if (Key[0] == '\t' && !(Qualifier & ~(IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))) return(TRUE);
  136.     // Now check for special characters
  137.     Key[0] = IUtility->ToUpper(Key[0]);
  138.     if (!GotIt) {
  139.       for(i = 0; KeyTable[i].Code; i++) {
  140.         if (KeyTable[i].Code == Key[0]) {
  141.           KeyName = KeyTable[i].Name;
  142.           GotIt = TRUE;
  143.           break;
  144.         }
  145.       }
  146.     }
  147.     // If no special character is involved,
  148.     // use the vanilla character code
  149.     if (!GotIt) {
  150.       if ((Key[0] > ' ' && Key[0] < 127) || Key[0] >= 160) {
  151.         Key[1] = 0;
  152.         KeyName = Key;
  153.       }
  154.       else {
  155.         Work->Actions  = (Work->Actions & ~SGA_USE) | SGA_BEEP;
  156.         return(TRUE);
  157.       }
  158.     }
  159.   }
  160.   else {
  161.     // Special raw key code table
  162.     static struct {
  163.       UWORD Code;
  164.       STRPTR Name;
  165.     } RawTable[] = {
  166.       RAWKEY_CURSOR_UP,    "Cursor_Up",
  167.       RAWKEY_CURSOR_DOWN,  "Cursor_Down",
  168.       RAWKEY_CURSOR_RIGHT, "Cursor_Right",
  169.       RAWKEY_CURSOR_LEFT,  "Cursor_Left",
  170.  
  171.       RAWKEY_F1,    "F1",
  172.       RAWKEY_F2,    "F2",
  173.       RAWKEY_F3,    "F3",
  174.       RAWKEY_F4,    "F4",
  175.       RAWKEY_F5,    "F5",
  176.       RAWKEY_F6,    "F6",
  177.       RAWKEY_F7,    "F7",
  178.       RAWKEY_F8,    "F8",
  179.       RAWKEY_F9,    "F9",
  180.       RAWKEY_F10,   "F10",
  181.  
  182.       RAWKEY_HELP,  "Help",
  183.  
  184.       0
  185.     };
  186.     WORD i;
  187.     // One eventually must match
  188.     for(i = 0; RawTable[i].Code; i++) {
  189.       if (Code == RawTable[i].Code) {
  190.         KeyName = RawTable[i].Name;
  191.         break;
  192.       }
  193.     }
  194.   }
  195.  
  196.   // Take care of the qualifiers. Note that we do not distinguish
  197.   // between the left and right shift/alt keys
  198.  
  199.   if (Qualifier) {
  200.     static struct {
  201.       ULONG Qualifier;
  202.       STRPTR Name;
  203.     } QualifierTable[] = {
  204.       IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT, "Shift ",
  205.       IEQUALIFIER_LALT | IEQUALIFIER_RALT,     "Alt ",
  206.       IEQUALIFIER_LCOMMAND,                    "LAmiga ",
  207.       IEQUALIFIER_RCOMMAND,                    "RAmiga ",
  208.       IEQUALIFIER_LEFTBUTTON,                  "Left_Button ",
  209.       IEQUALIFIER_MIDBUTTON,                   "Middle_Button ",
  210.       IEQUALIFIER_RBUTTON,                     "Right_Button ",
  211.       IEQUALIFIER_NUMERICPAD,                  "Numeric_Pad ",
  212.  
  213.       0
  214.     };
  215.     WORD i;
  216.     // Ok, now start building the string
  217.     Work->WorkBuffer[0] = 0;
  218.     for(i = 0; QualifierTable[i].Qualifier; i++) {
  219.       if (Qualifier & QualifierTable[i].Qualifier) strcat(Work->WorkBuffer,QualifierTable[i].Name);
  220.     }
  221.     // Add the key itself
  222.     strcat(Work->WorkBuffer,KeyName);
  223.     // Update the work data
  224.     Work->NumChars  = strlen(Work->WorkBuffer);
  225.     Work->BufferPos = Work->NumChars;
  226.     // Finished...
  227.     Work->Actions = (Work->Actions & ~(SGA_BEEP | SGA_PREVACTIVE | SGA_NEXTACTIVE | SGA_END)) | SGA_REDISPLAY | SGA_USE;
  228.   }
  229.   else Work->Actions &= ~(SGA_USE | SGA_BEEP);
  230.  
  231.   return(TRUE);
  232.  
  233. }
  234.  
  235.  
  236.   /* UpdateModeString():
  237.    *
  238.    *  This routine builds the screen mode and screen depth string
  239.    *  for the user interface.
  240.    */
  241.  
  242. VOID
  243. UpdateModeString()
  244. {
  245.   WORD Len;
  246.  
  247.   if (!GetModeName(DisplayID,DisplayModeBuffer))
  248.     strcpy(DisplayModeBuffer,"«Default screen mode»");
  249.  
  250.   Len = strlen(DisplayModeBuffer);
  251.  
  252.   if (Depth)
  253.     SPrintf(&DisplayModeBuffer[Len],", %ld colours",1L << Depth);
  254.   else
  255.     strcpy(&DisplayModeBuffer[Len],", «Maximum depth»");
  256. }
  257.  
  258.   /* ShowTime(struct Gadget *SomeGadget,WORD Level):
  259.    *
  260.    *  Gadtools support routine, displays the timeouts.
  261.    */
  262.  
  263. LONG __saveds __stdargs
  264. ShowTime(struct Gadget *SomeGadget,WORD Level)
  265. {
  266.   STATIC UBYTE Buffer[30];
  267.  
  268.   if (Level)
  269.     SPrintf(Buffer,"%2ld:%02ld min.",Level / 60,Level % 60);
  270.   else
  271.     SPrintf(Buffer,"«Off»");
  272.  
  273.   return((LONG)Buffer);
  274. }
  275.  
  276.   /* ShowDots(struct Gadget *SomeGadget,WORD Level):
  277.    *
  278.    *  Cheap trick; multiply the number of dots by 100.
  279.    */
  280.  
  281. LONG __saveds __stdargs
  282. ShowDots(struct Gadget *SomeGadget,WORD Level)
  283. {
  284.   return((LONG)Level * 100);
  285. }
  286.  
  287.   /* ShutdownWindow():
  288.    *
  289.    *  Closes the control panel.
  290.    */
  291.  
  292. VOID
  293. ShutdownWindow()
  294. {
  295.   if (Handle)
  296.   {
  297.     LT_DeleteHandle(Handle);
  298.  
  299.     Handle = NULL;
  300.  
  301.     Window = NULL;
  302.  
  303.     CloseLibrary(GTLayoutBase);
  304.  
  305.     GTLayoutBase = NULL;
  306.   }
  307. }
  308.  
  309.   /* SetupWindow():
  310.    *
  311.    *  Creates the control panel and disables the screen
  312.    *  blanker.
  313.    */
  314.  
  315. BOOL
  316. SetupWindow()
  317. {
  318.   if (Handle)
  319.   {
  320.     LT_ShowWindow(Handle,TRUE);
  321.  
  322.     return(TRUE);
  323.   }
  324.   else
  325.   {
  326.     if (!(GTLayoutBase = SafeOpenLibrary("PROGDIR:gtlayout.library",9)))
  327.       GTLayoutBase = SafeOpenLibrary("gtlayout.library",9);
  328.  
  329.     if (GTLayoutBase)
  330.     {
  331.       if (Handle = LT_CreateHandleTagList(NULL,NULL))
  332.       {
  333.         LT_New(Handle,
  334.           LA_Type,  VERTICAL_KIND,
  335.         TAG_DONE);
  336.         {
  337.           LT_New(Handle,
  338.             LA_LabelText,  "Fractal screen blanker",
  339.             LA_Type,  VERTICAL_KIND,
  340.           TAG_DONE);
  341.           {
  342.             STATIC STRPTR Copyright[] =
  343.             {
  344.               "Copyright © 1991-1995",
  345.               "by Olaf `Olsen' Barthel",
  346.               "All Rights Reserved",
  347.               NULL
  348.             };
  349.  
  350.             LT_New(Handle,
  351.               LA_Type,  BOX_KIND,
  352.               LABX_Lines,  Copyright,
  353.               LABX_AlignText,  ALIGNTEXT_CENTERED,
  354.               LA_DrawBox,  FALSE,
  355.             TAG_DONE);
  356.  
  357.             LT_EndGroup(Handle);
  358.           }
  359.  
  360.           LT_New(Handle,
  361.             LA_LabelText,  "Controls",
  362.             LA_Type,  VERTICAL_KIND,
  363.           TAG_DONE);
  364.           {
  365.             STATIC STRPTR FractalTypes[] =
  366.             {
  367.               "Real plane",
  368.               "Cosmic flames",
  369.               "« Random »",
  370.               NULL
  371.             };
  372.  
  373.             STATIC STRPTR ColourModes[] =
  374.             {
  375.               "Cycling",
  376.               "Static",
  377.               NULL
  378.             };
  379.  
  380.             LT_New(Handle,
  381.               LA_Type,    SLIDER_KIND,
  382.               LA_LabelText,    "Screen timeout",
  383.               GTSL_Min,    0,
  384.               GTSL_Max,    30 * 60,
  385.               GTSL_LevelFormat,  "%s",
  386.               GTSL_DispFunc,    ShowTime,
  387.               LA_ULONG,    &ScreenTimeout,
  388.               LA_Chars,    20,
  389.             TAG_DONE);
  390.  
  391.             LT_New(Handle,
  392.               LA_Type,    SLIDER_KIND,
  393.               LA_LabelText,    "Pattern timeout",
  394.               GTSL_Min,    0,
  395.               GTSL_Max,    30 * 60,
  396.               GTSL_LevelFormat,  "%s",
  397.               GTSL_DispFunc,    ShowTime,
  398.               LA_ULONG,    &PatternTimeout,
  399.             TAG_DONE);
  400.  
  401.             LT_New(Handle,
  402.               LA_Type,    XBAR_KIND,
  403.             TAG_DONE);
  404.  
  405.             EditHook.h_Entry = (HOOKFUNC)EditRoutine;
  406.  
  407.             LT_New(Handle,
  408.               LA_Type,    STRING_KIND,
  409.               LA_LabelText,    "Hot key",
  410.               GTST_MaxChars,    255,
  411.               GTST_String,    HotkeyBuffer,
  412.               GTST_EditHook,    &EditHook,
  413.               LA_ID,      GAD_HOTKEY,
  414.             TAG_DONE);
  415.  
  416.             LT_New(Handle,
  417.               LA_Type,    STRING_KIND,
  418.               LA_LabelText,    "Blank screen",
  419.               GTST_MaxChars,    255,
  420.               GTST_String,    BlankScreenBuffer,
  421.               GTST_EditHook,    &EditHook,
  422.               LA_ID,      GAD_BLANKSCREEN,
  423.             TAG_DONE);
  424.  
  425.             if (DataTypesBase)
  426.             {
  427.               LT_New(Handle,
  428.                 LA_Type,  STRING_KIND,
  429.                 LA_LabelText,  "Save screen to clipboard",
  430.                 GTST_MaxChars,  255,
  431.                 GTST_String,  SaveScreenBuffer,
  432.                 GTST_EditHook,  &EditHook,
  433.                 LA_ID,    GAD_SAVESCREEN,
  434.               TAG_DONE);
  435.             }
  436.  
  437.             LT_New(Handle,
  438.               LA_Type,    XBAR_KIND,
  439.             TAG_DONE);
  440.  
  441.             UpdateModeString();
  442.  
  443.             LT_New(Handle,
  444.               LA_Type,    TEXT_KIND,
  445.               LA_LabelText,    "Display mode",
  446.               LA_ID,      GAD_MODE,
  447.               GTTX_Text,    DisplayModeBuffer,
  448.               GTTX_Border,    TRUE,
  449.               LATX_Picker,    TRUE,
  450.             TAG_DONE);
  451.  
  452.             LT_New(Handle,
  453.               LA_Type,    XBAR_KIND,
  454.             TAG_DONE);
  455.  
  456.             LT_New(Handle,
  457.               LA_Type,    CYCLE_KIND,
  458.               LA_LabelText,    "Colour mode",
  459.               GTCY_Labels,    ColourModes,
  460.               LA_UBYTE,    &ColourMode,
  461.             TAG_DONE);
  462.  
  463.             LT_New(Handle,
  464.               LA_Type,    CYCLE_KIND,
  465.               LA_LabelText,    "Fractal type",
  466.               GTCY_Labels,    FractalTypes,
  467.               LA_UBYTE,    &FractalType,
  468.             TAG_DONE);
  469.  
  470.             LT_New(Handle,
  471.               LA_Type,    SLIDER_KIND,
  472.               LA_LabelText,    "Maximum recursion level",
  473.               GTSL_Min,    10,
  474.               GTSL_Max,    100,
  475.               GTSL_LevelFormat,  "%ld",
  476.               LA_ULONG,    &MaxRecursionLevel,
  477.             TAG_DONE);
  478.  
  479.             LT_New(Handle,
  480.               LA_Type,    SLIDER_KIND,
  481.               LA_LabelText,    "Maximum dots",
  482.               GTSL_Min,    10,
  483.               GTSL_Max,    1000,
  484.               GTSL_LevelFormat,  "%lD",
  485.               GTSL_DispFunc,    ShowDots,
  486.               LA_ULONG,    &MaxFlamePoints,
  487.             TAG_DONE);
  488.  
  489.             LT_EndGroup(Handle);
  490.           }
  491.  
  492.           LT_New(Handle,
  493.             LA_Type,  VERTICAL_KIND,
  494.           TAG_DONE);
  495.           {
  496.             LT_New(Handle,
  497.               LA_Type,    XBAR_KIND,
  498.               LAXB_FullSize,    TRUE,
  499.             TAG_DONE);
  500.  
  501.             LT_EndGroup(Handle);
  502.           }
  503.  
  504.           LT_New(Handle,
  505.             LA_Type,  HORIZONTAL_KIND,
  506.             LAGR_Spread,  TRUE,
  507.             LAGR_SameSize,  TRUE,
  508.           TAG_DONE);
  509.           {
  510.             if (!MainProcess->pr_CLI)
  511.             {
  512.               LT_New(Handle,
  513.                 LA_Type,  BUTTON_KIND,
  514.                 LA_LabelText,  "Save",
  515.                 LABT_ExtraFat,  TRUE,
  516.                 LA_ID,    GAD_SAVE,
  517.                 LA_Chars,  8,
  518.               TAG_DONE);
  519.             }
  520.  
  521.             LT_New(Handle,
  522.               LA_Type,  BUTTON_KIND,
  523.               LA_LabelText,  "Hide",
  524.               LABT_ReturnKey,  TRUE,
  525.               LABT_ExtraFat,  TRUE,
  526.               LA_ID,    GAD_HIDE,
  527.               LA_Chars,  8,
  528.             TAG_DONE);
  529.  
  530.             LT_New(Handle,
  531.               LA_Type,  BUTTON_KIND,
  532.               LA_LabelText,  "Quit",
  533.               LA_ID,    GAD_QUIT,
  534.             TAG_DONE);
  535.  
  536.             LT_EndGroup(Handle);
  537.           }
  538.  
  539.           LT_EndGroup(Handle);
  540.         }
  541.  
  542.         if (Window = LT_Build(Handle,
  543.           LAWN_IDCMP,    IDCMP_CLOSEWINDOW,
  544.           LAWN_BelowMouse,  TRUE,
  545.           LAWN_SmartZoom,    TRUE,
  546.           LAWN_TitleText,    &VersTag[7],
  547.           WA_DepthGadget,    TRUE,
  548.           WA_CloseGadget,    TRUE,
  549.           WA_DragBar,    TRUE,
  550.           WA_RMBTrap,    TRUE,
  551.           WA_Activate,    TRUE,
  552.         TAG_DONE))
  553.         {
  554.           ResetRequest = TRUE;
  555.  
  556.           return(TRUE);
  557.         }
  558.  
  559.         LT_DeleteHandle(Handle);
  560.  
  561.         Handle = NULL;
  562.       }
  563.  
  564.       ReportError(NULL,NULL,ERR_NoWindow);
  565.  
  566.       CloseLibrary(GTLayoutBase);
  567.  
  568.       GTLayoutBase = NULL;
  569.     }
  570.     else
  571.       ReportError(NULL,NULL,ERR_NoGTLayout);
  572.  
  573.     return(FALSE);
  574.   }
  575. }
  576.  
  577.  
  578. BOOL HandleWindowInput(ULONG SignalSet) {
  579.  
  580.       if (SignalSet & SIG_WINDOW) {
  581.         struct IntuiMessage  *IMsg;
  582.         BOOL       Hide = FALSE;
  583.         ULONG       MsgClass;
  584.         struct Gadget    *MsgGadget;
  585.         ULONG       LocalID,LocalDepth;
  586.         IX       Expression;
  587.         BOOL       NewKeys;
  588.         STRPTR       String;
  589.         LONG       Error;
  590.         struct IBox     Box;
  591.  
  592.         while(IMsg = LT_GetIMsg(Handle))
  593.         {
  594.           MsgClass  = IMsg->Class;
  595.           MsgGadget  = (struct Gadget *)IMsg->IAddress;
  596.  
  597.           LT_ReplyIMsg(IMsg);
  598.  
  599.           switch(MsgClass)
  600.           {
  601.             case IDCMP_CLOSEWINDOW:
  602.  
  603.               Hide = TRUE;
  604.               break;
  605.  
  606.             case IDCMP_GADGETUP:
  607.  
  608.               switch(MsgGadget->GadgetID)
  609.               {
  610.                 case GAD_QUIT:
  611.  
  612.                   Done = TRUE;
  613.                   break;
  614.  
  615.                   // Make sure that the key
  616.                   // codes are correct
  617.  
  618.                 case GAD_BLANKSCREEN:
  619.                 case GAD_SAVESCREEN:
  620.                 case GAD_HOTKEY:
  621.  
  622.                   if (ParseIX(LT_GetString(Handle,MsgGadget->GadgetID),&Expression))
  623.                   {
  624.                     DisplayBeep(Window->WScreen);
  625.  
  626.                     LT_Activate(Handle,MsgGadget->GadgetID);
  627.                   }
  628.  
  629.                   break;
  630.  
  631.                 case GAD_HIDE:
  632.                 case GAD_SAVE:
  633.  
  634.                   LT_LockWindow(Window);
  635.  
  636.                     // Update the Commodities
  637.                     // interface only if the
  638.                     // key assignments have
  639.                     // changed
  640.  
  641.                   NewKeys = FALSE;
  642.  
  643.                   String = LT_GetString(Handle,GAD_HOTKEY);
  644.  
  645.                   if (!ParseIX(String,&Expression))
  646.                   {
  647.                     IX OldExpression;
  648.  
  649.                     ParseIX(HotkeyBuffer,&OldExpression);
  650.  
  651.                     if (memcmp(&Expression,&OldExpression,sizeof(IX)))
  652.                     {
  653.                       SpecialQualifier = SubQualifier(HotkeyBuffer,SpecialQualifier);
  654.  
  655.                       strcpy(HotkeyBuffer,String);
  656.  
  657.                       SpecialQualifier = AddQualifier(HotkeyBuffer,SpecialQualifier);
  658.  
  659.                       NewKeys = TRUE;
  660.                     }
  661.                   }
  662.  
  663.                   String = LT_GetString(Handle,GAD_BLANKSCREEN);
  664.  
  665.                   if (!ParseIX(String,&Expression))
  666.                   {
  667.                     IX OldExpression;
  668.  
  669.                     ParseIX(BlankScreenBuffer,&OldExpression);
  670.  
  671.                     if (memcmp(&Expression,&OldExpression,sizeof(IX)))
  672.                     {
  673.                       SpecialQualifier = SubQualifier(BlankScreenBuffer,SpecialQualifier);
  674.  
  675.                       strcpy(BlankScreenBuffer,String);
  676.  
  677.                       SpecialQualifier = AddQualifier(BlankScreenBuffer,SpecialQualifier);
  678.  
  679.                       NewKeys = TRUE;
  680.                     }
  681.                   }
  682.  
  683.                   String = LT_GetString(Handle,GAD_SAVESCREEN);
  684.  
  685.                   if (!ParseIX(String,&Expression))
  686.                   {
  687.                     IX OldExpression;
  688.  
  689.                     ParseIX(SaveScreenBuffer,&OldExpression);
  690.  
  691.                     if (memcmp(&Expression,&OldExpression,sizeof(IX)))
  692.                     {
  693.                       SpecialQualifier = SubQualifier(SaveScreenBuffer,SpecialQualifier);
  694.  
  695.                       strcpy(SaveScreenBuffer,String);
  696.  
  697.                       SpecialQualifier = AddQualifier(SaveScreenBuffer,SpecialQualifier);
  698.  
  699.                       NewKeys = TRUE;
  700.                     }
  701.                   }
  702.  
  703.                   LT_UnlockWindow(Window);
  704.  
  705.                   if (NewKeys)
  706.                   {
  707.                     if (Error = SetupCx())
  708.                     {
  709.                       if (Error != ERR_Duplicate)
  710.                         ReportError(Window,NULL,Error);
  711.  
  712.                       CloseAll(RETURN_FAIL);
  713.                     }
  714.                   }
  715.  
  716.                   if (MsgGadget->GadgetID == GAD_HIDE)
  717.                     Hide = TRUE;
  718.                   else
  719.                     SaveOptions(argv);
  720.  
  721.                   break;
  722.               }
  723.  
  724.               break;
  725.  
  726.               // Pick a new display mode
  727.  
  728.             case IDCMP_IDCMPUPDATE:
  729.  
  730.               if (DisplayID == INVALID_ID)
  731.                 LocalID = GetVPModeID(&Window->WScreen->ViewPort);
  732.               else
  733.                 LocalID = DisplayID;
  734.  
  735.               if (Depth)
  736.                 LocalDepth = Depth;
  737.               else
  738.               {
  739.                 struct DimensionInfo DimensionInfo;
  740.  
  741.                 if (GetDisplayInfoData(NULL,(APTR)&DimensionInfo,sizeof(DimensionInfo),DTAG_DIMS,LocalID))
  742.                   LocalDepth = DimensionInfo.MaxDepth;
  743.                 else
  744.                   LocalDepth = 2;
  745.               }
  746.  
  747.               if (ScreenModeRequest->sm_UserData && !ResetRequest)
  748.                 CopyMem(&ScreenModeRequest->sm_LeftEdge,&Box,sizeof(struct IBox));
  749.               else
  750.               {
  751.                 CopyMem(&Window->LeftEdge,&Box,sizeof(struct IBox));
  752.  
  753.                 Box.Top  += Window->BorderTop;
  754.                 Box.Height  -= Window->BorderTop;
  755.               }
  756.  
  757.               if (AslRequestTags(ScreenModeRequest,
  758.                 ASLSM_Window,      Window,
  759.                 ASLSM_SleepWindow,    TRUE,
  760.                 ASLSM_InitialDisplayID,    LocalID,
  761.                 ASLSM_InitialDisplayDepth,  LocalDepth,
  762.                 ASLSM_UserData,      TRUE,
  763.                 ASLSM_InitialLeftEdge,    Box.Left,
  764.                 ASLSM_InitialTopEdge,    Box.Top,
  765.                 ASLSM_InitialWidth,    Box.Width,
  766.                 ASLSM_InitialHeight,    Box.Height,
  767.               TAG_DONE))
  768.               {
  769.                 ResetRequest = FALSE;
  770.  
  771.                 DisplayID  = ScreenModeRequest->sm_DisplayID;
  772.                 Depth    = ScreenModeRequest->sm_DisplayDepth;
  773.  
  774.                 UpdateModeString();
  775.  
  776.                 LT_SetAttributes(Handle,GAD_MODE,
  777.                   GTTX_Text,  DisplayModeBuffer,
  778.                 TAG_DONE);
  779.               }
  780.               else
  781.                 ResetRequest = TRUE;
  782.  
  783.               break;
  784.           }
  785.         }
  786.  
  787.         if (Hide)
  788.           ShutdownWindow();
  789.       } 
  790.  
  791. }
  792.